<?php
/*
UploadiFive
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
*/

session_start();

// Set the uplaod directory
$uploadDir = '/uploads/';

// Set the allowed file extensions
$fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // Allowed file extensions

if (!empty($_FILES)) {
	$tempFile   = $_FILES['Filedata']['tmp_name'];
	//$uploadDir  = $_SERVER['DOCUMENT_ROOT'] . $uploadDir;
        $uploadDir  = __DIR__ . $uploadDir;
        $today = date("YmdHms");
         $targetFile = $uploadDir . $_FILES['Filedata']['size']."@". $_FILES['Filedata']['name'];

	// Validate the filetype
	$fileParts = pathinfo($_FILES['Filedata']['name']);
	if (in_array(strtolower($fileParts['extension']), $fileTypes)) {

		// Save the file
                
                $_SESSION["vull"] = $tempFile;
            
		move_uploaded_file($tempFile, $targetFile);

	} else {

		// The file type wasn't allowed
		echo 'Invalid file type.';

	}
}
?>